<?php

/**
 * 单例类
 * Class Singleton
 */
final class President
{
    private static $instance;

    public function __construct()
    {
    }

    public static function getInstance(): President
    {
        if (!self::$instance) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    public function __clone()
    {
        // disable clone
    }

    public function __wakeup()
    {
        // disable unserialize
    }
}

// usage
$president1 = President::getInstance();
$president2 = President::getInstance();

var_dump($president1 === $president2);